﻿/**
 * This is a part of MCServe, which is available under the Apache license 2.0.
 * With this code, you may do whatever you want as long as that is not in conflict with this license.
 * In addition, you should have a reference to the original project to include (http://mcserve.codeplex.com).
 * 
 * Author       : Lars Krämer ( Xe77a )
 * Website      : http://www.lkraemer.de
 * Project      : MCServe (http://mcserve.codeplex.com)
 * Copyright    : Copyright (c) 2013 lkraemer.de
 * License      : http://mcserve.codeplex.com/license
 * Description  : This is a part of the core functionality of the server
 */

using System;
using System.ComponentModel;

namespace MCServeCore.PlayerObjects
{
    public class Player : INotifyPropertyChanged
    {
        private PlayerType _Type = PlayerType.GUEST;
        private String _Name = "";
        private String _Clan = "";
        private Guid _Guid = new Guid();
        private Boolean _CanKick = false;
        private Boolean _CanBan = false;

        /**
         * Konstruktor
         */
        public Player()
        {
            Type = PlayerType.GUEST;
            Name = "Unknown Player";
            _Guid = Guid.NewGuid();
            CanBan = false;
            CanKick = false;
        }

        public PlayerType Type
        {
            get
            {
                return _Type;
            }
            set
            {
                _Type = value;
                NotifyPropertyChanged(x => x.Type);
            }
        }
        public String Name
        {
            get
            {
                return _Name;
            }
            set
            {
                _Name = value;
                NotifyPropertyChanged(x => x.Name);
            }
        }
        public String Clan
        {
            get
            {
                return _Clan;
            }
            set
            {
                _Clan = value;
                NotifyPropertyChanged(x => x.Clan);
            }
        }
        public Guid Guid
        {
            get
            {
                return _Guid;
            }
        }
        public Boolean CanKick
        {
            get
            {
                return _CanKick;
            }
            set
            {
                _CanKick = value;
                NotifyPropertyChanged(x => x.CanKick);
            }
        }
        public Boolean CanBan
        {
            get
            {
                return _CanBan;
            }
            set
            {
                _CanBan = value;
                NotifyPropertyChanged(x => x.CanBan);
            }
        }

        #region INotifyPropertyChanged Member

        public event PropertyChangedEventHandler PropertyChanged;
        private void NotifyPropertyChanged<TValue> (System.Linq.Expressions.Expression<Func<Player, TValue>> propertySelector)
        {
            if (PropertyChanged != null)
            {
                var memberExpression = propertySelector.Body as System.Linq.Expressions.MemberExpression;
                if (memberExpression != null)
                {
                    PropertyChanged(this, new PropertyChangedEventArgs(memberExpression.Member.Name));
                }
            }
        }
        #endregion

    }

    public class ServerPlayer : Player
    {
        public ServerPlayer(String name)
        {
            Type = PlayerType.SERVER;
            CanBan = true;
            CanKick = true;
            Name = name;
            Clan = "";
        }
        public ServerPlayer(String name, String clan)
        {
            Type = PlayerType.SERVER;
            CanBan = true;
            CanKick = true;
            Name = name;
            Clan = clan;
        }
    }

    public class AdminPlayer : Player
    {
        public AdminPlayer(String name)
        {
            Type = PlayerType.ADMINISTRATOR;
            CanBan = true;
            CanKick = true;
            Name = name;
            Clan = "";
        }
        public AdminPlayer(String name, String clan)
        {
            Type = PlayerType.ADMINISTRATOR;
            CanBan = true;
            CanKick = true;
            Name = name;
            Clan = clan;
        }
    }

    public class MemberPlayer : Player
    {
        public MemberPlayer(String name)
        {
            Type = PlayerType.MEMBER;
            CanBan = false;
            CanKick = false;
            Name = name;
            Clan = "";
        }
        public MemberPlayer(String name, String clan)
        {
            Type = PlayerType.MEMBER;
            CanBan = false;
            CanKick = false;
            Name = name;
            Clan = clan;
        }
    }

    public class ModeratorPlayer : Player
    {
        public ModeratorPlayer(String name)
        {
            Type = PlayerType.MODERATOR;
            CanBan = false;
            CanKick = true;
            Name = name;
            Clan = "";
        }
        public ModeratorPlayer(String name, String clan)
        {
            Type = PlayerType.MODERATOR;
            CanBan = false;
            CanKick = true;
            Name = name;
            Clan = clan;
        }
    }
}
